package com.wuseguang.springcloud.service.impl;

import com.wuseguang.springcloud.dao.jdbc.NoticeSeeJdbc;
import com.wuseguang.springcloud.service.NoticeSeeService;
import com.wuseguang.springcloud.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 通知未查看 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-09-17
 */
@Service
public class NoticeSeeServiceImpl  implements NoticeSeeService {
    @Autowired
    private NoticeSeeJdbc noticeSeeJdbc;

    @Override
    public Result findNoticeSee(Integer studentId) {
        //查询没有查看的通知
        String sql = "select jurisdiction_id,count(jurisdiction_id) count,DATE_FORMAT(MAX(add_time),'%H:%i') add_time " +
                "from notice_see where  student_id = ? and type =0 GROUP BY jurisdiction_id";
        List<Map<String,Object>> list = noticeSeeJdbc.queryListMap(sql,studentId);
        return new Result(list);
    }

    @Override
    public Result informAndCheckNoticeSee(Integer studentId, Integer jurisdictionId) {

        //查询没有查看的通知
        String sql = "UPDATE  `notice_see` SET `type` = 1 WHERE `student_id` = ? and `jurisdiction_id` = ?";
        noticeSeeJdbc.updateByParameter(sql,studentId,jurisdictionId);
        return new Result();
    }
}
